<%--
  Created by IntelliJ IDEA.
  User: wjc
  Date: 2021/4/8
  Time: 9:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <!-- 引入 Bootstrap -->
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <!-- jQuery (Bootstrap 的 JavaScript 插件需要引入 jQuery) -->
    <script src="https://code.jquery.com/jquery.js"></script>
    <title>橡树科技－JavaDemoSystem</title>
    <link type="text/css" rel="stylesheet" media="all" href="/static/styles/global.css" />
    <link type="text/css" rel="stylesheet" media="all" href="/static/styles/global_color.css" />
    <script language="javascript" type="text/javascript">
        //保存成功的提示消息
        function showResult() {
            showResultDiv(true);
            window.setTimeout("showResultDiv(false);", 3000);
            var name = $("input[name='name']").val();
            var adminCode = $("input[name='adminCode']").val();
            var telPhone = $("input[name='telPhone']").val();
            var email = $("input[name='email']").val();
            var roles = $("input[type='checkbox']:checked").val();
            var json = {"name":name,"adminCode":adminCode,"telPhone":telPhone,"email":email,"roles":roles};
            $.ajax({
                url:'${pageContext.request.contextPath}/admin/admin_modi',
                type:'post',
                contentType:"application/json",
                data:JSON.stringify(json),
                success:function(ret){

                }
            })
        }
        function showResultDiv(flag) {
            var divResult = document.getElementById("save_result_info");
            if (flag)
                divResult.style.display = "block";
            else
                divResult.style.display = "none";
        }


    </script>
</head>
<body>
<div id="header"> <img src="/static/images/logo.png" alt="logo" class="left"/> <a href="/logout">[退出]</a> </div>
<div id="navi">
    <ul id="menu">
        <li><a href="${pageContext.request.contextPath}/index" class="index_on"></a></li>
        <c:forEach items="${list}" var="c">
            <li><a href="${pageContext.request.contextPath}/${c.url}" class="index_on"></a></li>
        </c:forEach>
        <li><a href="user/user_info.html" class="information_off"></a></li>
        <li><a href="user/user_modi_pwd.html"  class="password_off"></a></li>
    </ul>
</div>
<div id="main">
    <div id="save_result_info" class="save_success">保存成功！</div>
    <form action="/admin/admin_modi" method="post" class="main_form">
        <input type="hidden" name="adminId" value="${adminInfo.adminId}">
        <div class="text_info clearfix"><span>姓名：</span></div>
        <div class="input_info">
            <input type="text" name="name" value="${adminInfo.name}"/>
            <span class="required">*</span>
            <div class="validate_msg_long error_msg" >20长度以内的汉字、字母、数字的组合</div>
        </div>
        <div class="text_info clearfix"><span>管理员账号：</span></div>
        <div class="input_info">
            <input type="text" name="adminCode" readonly="readonly" class="readonly" value="${adminInfo.adminCode}"/>
        </div>
        <div class="text_info clearfix"><span>电话：</span></div>
        <div class="input_info">
            <input type="text" name="telPhone" value="${adminInfo.telPhone}"/>
            <span class="required">*</span>
            <div class="validate_msg_long error_msg">正确的电话号码格式：手机或固话</div>
        </div>
        <div class="text_info clearfix"><span>Email：</span></div>
        <div class="input_info">
            <input type="text" class="width200" name="email" value="${adminInfo.email}"/>
            <span class="required">*</span>
            <div class="validate_msg_medium error_msg">50长度以内，正确的 email 格式</div>
        </div>
        <div class="text_info clearfix"><span>角色：</span></div>
        <div class="input_info_high">
            <div class="input_info_scroll">
                <ul>
                    <c:forEach items="${roleInfos}" var="roleInfo">
                        <li>
                            <input type="checkbox" name="roles" value="${roleInfo.roleId}" ${fn:contains(adminInfo.allRoleInfoNames,roleInfo.name)?"checked='checked'":""} />
                                ${roleInfo.name}</li>
                    </c:forEach>
                </ul>
            </div>
            <span class="required">*</span>
            <div class="validate_msg_tiny error_msg">至少选择一个</div>
        </div>
        <div class="button_info clearfix">
            <input type="submit" value="保存" class="btn_save" onClick="showResult();"/>
            <input type="button" value="取消" class="btn_save"/>
        </div>
    </form>
</div>
<div id="footer"> <span>[源自橡树的技术，最优秀的师资，最真实的企业环境，最适用的实战项目]</span> <br/>
    <span>版权所有(C)橡树信息科技有限公司 </span> </div>
</body>
</html>
